/*
 * Copyright (c) 2009 Project E7
 *
 * This file is part of ZebBowling
 *
 * ZebBowling is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZebBowling is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZebBowling. If not, see <http://www.gnu.org/licenses/>.
 **/

package org.sunspotworld;

import org.zebbowling.control.ControllerBaseStation;
import org.zebbowling.control.ZBowlingController;
import org.zebbowling.world.BowlingFrame;
import org.zebbowling.world.SpotBowlingLane;

/**
 * Sample Sun SPOT host application
 */
public class SunSpotHostApplication {

    public static volatile int t = 10;
    private BowlingFrame bf;

    public SunSpotHostApplication(BowlingFrame bf) {
        this.bf = bf;
        }

    /**
     * Sets up the <code>ControllerBaseStation</code> to allow four connections
     */
    public void run() {
        SpotBowlingLane alley = (SpotBowlingLane) bf.getAlley();
        ControllerBaseStation cbs = new ControllerBaseStation();
        cbs.addPorts(new int[] {101,102,103,104});
        cbs.setControlHandlers(ZBowlingController.createControllers(alley, 4));
        cbs.openConnAllPorts();      
        }

    /**
     * Start up the host application.
     *
     * @param args any command line arguments
     */
    public static void main(String[] args) {       
        BowlingFrame frame = new BowlingFrame("Zebulon Bowling");
        SunSpotHostApplication app = new SunSpotHostApplication(frame);
        app.run();
        }
}
